package com.sh.foa.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;

@Controller
@RequestMapping(value ="foa")
@Api(tags = {"foa"})
public class FoaController {
	
	@ResponseBody
	@RequestMapping(value = "login", method = {RequestMethod.POST,RequestMethod.GET})
	@ApiOperation(httpMethod = "POST,GET", value = "登录", notes = "用户登录")//swagger 当前接口注解
	@ApiImplicitParams({
		  @ApiImplicitParam(name="idUser",value="用户id",dataType="string",required=true, paramType = "query",example="2c46b9afa74f467799371e37b8e90b6d")})
	//swagger返回值注解
	@ApiResponses(value = {
		@ApiResponse(code = 500, message = "系统错误"),
	        @ApiResponse(code = 200, message = "成功,返回格式：{code:0,msg:'',data[{}]},data中的属性参照下方Model", response = void.class) })	
	public String login(HttpServletRequest request, HttpServletResponse response) {
		com.sh.common.LogUtil.getAppDebugLog().debug("foa.login");
		String loginName = request.getParameter("loginName");
		String password = request.getParameter("password");
		com.sh.common.LogUtil.getAppDebugLog().debug("loginName=" + loginName);
//		String strVoBean = request.getParameter("dataVoBeanType");
//		String strMenuNameMain = request.getParameter("dataMenuNameMain");
//		String strMenuCodeMain = request.getParameter("dataMenuCodeMain");
//		String strMenuNameChild = request.getParameter("dataMenuNameChild");
//		String strMenuCodeChild = request.getParameter("dataMenuCodeChild");
		//class.getClass(strVoBean)
		
		try {
			response.getWriter().write("{\"success\":\"true\"}");
		} catch (Exception e) {
//			com.data.core.common.util.LogUtil.getAppDebugLog().error("updateDeptRole更新失败", e);
//			try {
//				response.getWriter().write("更新失败");
//			} catch (IOException e1) {
////				com.data.core.common.util.LogUtil.getAppDebugLog().error("updateDeptRole更新失败2", e1);
//			}
		}
		
		return null;
	}
	
	@ResponseBody
	@RequestMapping(value = "showOpenMainFrame", method = {RequestMethod.POST,RequestMethod.GET})
	@ApiOperation(httpMethod = "POST,GET", value = "显示首页", notes = "进入用户主界面")//swagger 当前接口注解
	@ApiImplicitParams({
		  @ApiImplicitParam(name="idUser",value="用户id",dataType="string",required=true, paramType = "query",example="2c46b9afa74f467799371e37b8e90b6d")})
	//swagger返回值注解
	@ApiResponses(value = {
		@ApiResponse(code = 500, message = "系统错误"),
	        @ApiResponse(code = 200, message = "成功,返回格式：{code:0,msg:'',data[{}]},data中的属性参照下方Model", response = void.class) })	
	public ModelAndView showOpenMainFrame(HttpServletRequest request, HttpServletResponse response) {
		com.sh.common.LogUtil.getAppDebugLog().debug("foa.showOpenMainFrame");
		ModelAndView mav = new ModelAndView();
//		mav.addObject("dataVoAsParam", "com.ysxn.assets.model.VoAsParam");
//		String idParent=request.getParameter("idParent");
//		String idBusinessObject=request.getParameter("businessObject");
//		 
//	 
//		mav.addObject("idBusinessObject", idBusinessObject);
//		mav.addObject("idParent", idParent);
		mav.setViewName("/public/mainframetab");
		return mav;
	}
}
